﻿using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using BilbilBLL;
using Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Modles.DTO;
using Modles.Models;

namespace bilbil.Controllers
{
    /// <summary>
    /// 通用功能
    /// </summary>
    /// 


    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UniversalFunctionality : ControllerBase
    {
        UniversalFunctionalityServer universalFunctionalityServer = new UniversalFunctionalityServer();
        /// <summary>
        /// 根据用户信息表id打印用户信息表数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        [Authorize]
        public IActionResult GetUserInfo()
        {
            int userId1 = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier)?.Value);
            ResponseTool res = universalFunctionalityServer.GetUserInfo(userId1);
            return new JsonResult(res);
        }
    }
}
